/**
 * Project: complex.spring.advance
 * 
 * File Created at 2010-4-20
 * $Id$
 * 
 * Copyright 2008 Alibaba.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Alibaba Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Alibaba.com.
 */
package com.complex.spring.advance.service.impl;

import org.springframework.beans.factory.FactoryBean;

import com.complex.spring.advance.service.ITestA;

/**
 * @description:FactoryBean用于生成具体实例
 * @author gaoliang
 * @date 2010-4-20
 * @version 1.0
 */
public class TestFactoryBean implements FactoryBean {

    private ITestA testA;

    private String type;

    //testA的作用是为了产生TestFImpl,不是TestFactoryBean自身需要
    //type则是用于判断生成类型,是TestFactoryBean需要的
    public Object getObject() throws Exception {
        TestFImpl testF = new TestFImpl();
        if ("A".equals(type)) {
            testF.setTestA(testA);
        }

        return testF;
    }

    @SuppressWarnings("unchecked")
    public Class getObjectType() {
        return TestFImpl.class;
    }

    public boolean isSingleton() {
        return true;
    }

    public ITestA getTestA() {
        return testA;
    }

    public void setTestA(ITestA testA) {
        this.testA = testA;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

}
